package csel.controller.commands;

import java.util.HashMap;

import csel.controller.commandutil.Parameterizable;
import csel.controller.enums.ActionEnum;
import csel.model.Direction;
import csel.model.Model;

public class MoveCommand implements Parameterizable
{

	private Model model;
	private HashMap<ActionEnum, Direction> directionHashMap;
	private ActionEnum actionEnum;
	
	public MoveCommand(Model model)
	{
		this.model = model;
		this.directionHashMap = new HashMap<ActionEnum, Direction>();
		directionHashMap.put(ActionEnum.MOVE_EAST, Direction.EAST);
		directionHashMap.put(ActionEnum.MOVE_NORTH, Direction.NORTH);
		directionHashMap.put(ActionEnum.MOVE_NORTHEAST, Direction.NORTHEAST);
		directionHashMap.put(ActionEnum.MOVE_NORTHWEST, Direction.NORTHWEST);
		directionHashMap.put(ActionEnum.MOVE_SOUTH, Direction.SOUTH);
		directionHashMap.put(ActionEnum.MOVE_SOUTHEAST, Direction.SOUTHEAST);
		directionHashMap.put(ActionEnum.MOVE_SOUTHWEST, Direction.SOUTHWEST);
		directionHashMap.put(ActionEnum.MOVE_WEST, Direction.WEST);
	}
	
	public void parameterize(ActionEnum actionEnum)
	{
		this.actionEnum = actionEnum;
	}

	
	public void execute()
	{
		model.getPlayerCharacter().move(directionHashMap.get(actionEnum));
	}
	
	public MoveCommand clone()
	{
		try
		{
			MoveCommand clone = (MoveCommand)super.clone();
			return clone;
		} catch (CloneNotSupportedException e)
		{
			e.printStackTrace();
			return null;
		}
		
	}
	
//	private void setModel(Model model){
//		this.model = model;
//	}

}
